/*
 * SeparatorDelegate.h  0.4.0 / Dec 05, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
#ifndef SEPARATORDELEGATE_H
#define SEPARATORDELEGATE_H

#include "Cute4jSwing.h"

#include "ActionComponentDelegate.h"
#include "QSeparatorAdapter.h"

// SeparatorData Class. --------------------------------------------------------

/*!
 * \brief Separator Data.
 *
 * \author Slobodan Vrkacevic
 * \version 0.4.0
 */
class CUTE4J_EXPORT SeparatorData : public ActionComponentData  // TODO: considre to remvoe CUTE4J_EXPORT here
{
  friend class SeparatorDelegate;  // uses all members
protected:
  SeparatorData();
public:
  // TODO: implement getters
protected:
  Qt::Orientation orientation;
};

// SeparatorDelegate Class. ----------------------------------------------------

/*!
 * \brief Separator Delegate.
 *
 * \author Slobodan Vrkacevic
 * \version 0.4.0
 */
class CUTE4J_EXPORT SeparatorDelegate : public ActionComponentDelegate
{
  Q_OBJECT
protected:
  SeparatorDelegate(JNIEnv *env, jobject obj);
public slots: // native calls
  void setOrientation(JNIEnv *env, jint orientation);
  void setText(JNIEnv *env, jstring text);
public: // native calls
  static void initialize(JNIEnv *env, jclass cls);
  static jlong newInstance(JNIEnv *env, jobject obj);
public: // native callbacks
  void orientationChanged(jint orientation);
public:
  virtual void setParentDelegate(ContainerDelegate *parentDelegate);
  virtual void setForeground(JNIEnv *env, jint argb);
  virtual void setNullForeground(JNIEnv *env);
protected slots:
  void orientationChangedSlot(Qt::Orientation orientation);
protected:
  inline SeparatorData *separatorActionData();
  inline QSeparatorAdapter *separator() const;
protected:
  virtual QWidget *createQWidget();
  virtual QAction *createQAction();
  virtual QWidget *convertToQWidget(QAction *action);
  virtual QAction *convertToQAction(QWidget *widget);
  virtual ActionComponentData *createActionData();
private:
  static jmethodID sm_orientationChangedMID;
};

// SeparatorDelegate :: Protected Inline Member Functions. ---------------------

/*!
 * \brief Returns action data of the separator.
 *
 * \return action data of the separator
 */
inline SeparatorData *SeparatorDelegate::separatorActionData()
{
  return static_cast<SeparatorData *>(actionData());
}

/*!
 * \brief Returns separator data member.
 *
 * \return separator data member
 */
inline QSeparatorAdapter *SeparatorDelegate::separator() const
{
  return static_cast<QSeparatorAdapter *>(widget());
}

// Macro Definition. -----------------------------------------------------------

#define SEPARATOR_DELEGATE (reinterpret_cast<SeparatorDelegate *>(delegate))

#endif // SEPARATORDELEGATE_H
